﻿# Monkey365 - the PowerShell Cloud Security Tool for Azure and Microsoft 365 (copyright 2022) by Juan Garrido
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

Function New-HtmlAboutAuthorModal{
    <#
        .SYNOPSIS

        .DESCRIPTION

        .INPUTS

        .OUTPUTS

        .EXAMPLE

        .NOTES
	        Author		: Juan Garrido
            Twitter		: @tr1ana
            File Name	: New-HtmlAboutAuthorModal
            Version     : 1.0

        .LINK
            https://github.com/silverhack/monkey365
    #>

    [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "", Scope="Function")]
    [CmdletBinding()]
    [OutputType([System.Xml.XmlElement])]
    param()
    Begin{
        #Create social media data
        $social_media = @(
            [ordered]@{
                class = "social-icon text-xs-center"
                target = "_blank"
                href = "https://x.com/tr1ana"
                i_object = "bi bi-twitter-x"
            },
            [ordered]@{
                class = "social-icon text-xs-center"
                target = "_blank"
                href = "https://es.linkedin.com/in/juangarridocaballero"
                i_object = "bi bi-linkedin"
            },
            [ordered]@{
                class = "social-icon text-xs-center"
                target = "_blank"
                href = "https://github.com/silverhack"
                i_object = "bi bi-github"
            },
            [ordered]@{
                class = "social-icon text-xs-center"
                target = "_blank"
                href = "https://bsky.app/profile/tr1ana.bsky.social"
                i_object = "bi bi-square-fill"
            }
        )
        #Juan Garrido image
        $img_src = ''
        #xml root
        [xml]$modal_body = '<div class="row"></div>'
        #Create right div
        $right_div = $modal_body.CreateNode([System.Xml.XmlNodeType]::Element, $modal_body.Prefix, 'div', $modal_body.NamespaceURI);
        #Set attributes
        [void]$right_div.SetAttribute('class',"col-9")
        #Create left div
        $left_div = $modal_body.CreateNode([System.Xml.XmlNodeType]::Element, $modal_body.Prefix, 'div', $modal_body.NamespaceURI);
        #Set attributes
        [void]$left_div.SetAttribute('class',"col-3 text-center")
        #Create empty div
        $empty_div = $modal_body.CreateNode([System.Xml.XmlNodeType]::Element, $modal_body.Prefix, 'div', $modal_body.NamespaceURI);
        #Set attributes
        [void]$empty_div.SetAttribute('style',"height: 10px")
        #Close div with empty value
        [void]$empty_div.AppendChild($modal_body.CreateTextNode([string]::Empty))
        #Create IMG
        $img_attributes = @{
            src = $img_src;
            alt = 'Juan Garrido';
            class = 'img-fluid z-depth-1-half rounded-circle';
        }
        $img_element = @{
            Name = 'img';
            Attributes = $img_attributes;
            Empty = $True;
            Template = $modal_body;
        }
        $img = New-HtmlTag @img_element
        #Create P tags
        $p_attributes = @{
            class = 'title mb-0';
        }
        $p_element = @{
            Name = 'p';
            Attributes = $p_attributes;
            Text = "Juan Garrido";
            InnerText = $True;
            Template = $modal_body;
        }
        $first_name_p_element = New-HtmlTag @p_element
        #Create second p element
        $p_attributes = @{
            class = 'text';
            style = 'font-size: 13px';
        }
        $p_element = @{
            Name = 'p';
            Attributes = $p_attributes;
            Text = "Former MVP Enterprise Security and Cloud and Datacenter Management";
            InnerText = $True;
            Template = $modal_body;
        }
        $second_p_element = New-HtmlTag @p_element
        #Create right div text
        #Create new P element
        $p_owner = $modal_body.CreateNode([System.Xml.XmlNodeType]::Element, $modal_body.Prefix, 'p', $modal_body.NamespaceURI);
        #Create strong tag
        $strong = $modal_body.CreateNode([System.Xml.XmlNodeType]::Element, $modal_body.Prefix, 'strong', $modal_body.NamespaceURI);
        #Set strong InnerText
        $strong.InnerText = "Principal Security Consultant"
        #Set P InnerText
        $p_owner.InnerText = "Juan Garrido is a "
        #Append data
        [void]$p_owner.AppendChild($strong)
        #Append data
        [void]$p_owner.AppendChild($modal_body.CreateTextNode(" at NCC Group UK Security Consulting, a full-service security consulting company offering world class penetration testing, security systems development, security education and software design verification. He is focused on security assessment, forensic and incident response. During his more than nine years as a security professional, he also has been working on several security projects and court investigations. Juan has written several technical books and security tools. He is the author of many security tool, and he also writes as frequent contributor on several technical magazines in Spain including, Trade Press and Digital Media. Juan has been recognized as a Microsoft Most Valuable Professional (MVP) in Enterprise Security, now called Cloud and Datacenter Management. He has participated as speaker at many conferences such as RootedCon, GsickMinds, DEFCON, Troopers, BlackHat, etc. You can find him on Twitter."))
        #Add to right div
        [void]$right_div.AppendChild($p_owner)
        #Add data to left div
        [void]$left_div.AppendChild($img)
        [void]$left_div.AppendChild($empty_div)
        [void]$left_div.AppendChild($first_name_p_element)
        [void]$left_div.AppendChild($second_p_element)
        #Add left and right div to first row
        [void]$modal_body.div.AppendChild($left_div)
        [void]$modal_body.div.AppendChild($right_div)
    }
    Process{
        #Create footer data
        $ul_object = $modal_body.CreateNode([System.Xml.XmlNodeType]::Element, $modal_body.Prefix, 'ul', $modal_body.NamespaceURI);
        #Set class to ul object
        [void]$ul_object.SetAttribute('class',"list-inline")
        foreach($social_element in $social_media){
            #Create li element
            $li_attr = @{
                class = 'list-inline-item';
            }
            $li_element = @{
                Name = 'li';
                Attributes = $li_attr;
                Empty = $True;
                Template = $modal_body;
            }
            $li_object = New-HtmlTag @li_element
            #Create i object
            $i_attr = @{
                class = $social_element.i_object;
            }
            $i_element = @{
                Name = 'i';
                Attributes = $i_attr;
                Empty = $True;
                Template = $modal_body;
            }
            $i_object = New-HtmlTag @i_element
            #Create a href element
            $a_attr = [ordered]@{
            }
            foreach($attr in $social_element.GetEnumerator()){
                if($attr.key -eq "class"){continue}
                [void]$a_attr.Add($attr.key,$attr.Value)
            }
            $a_element = @{
                Name = 'a';
                Attributes = $a_attr;
                Empty = $True;
                Template = $modal_body;
            }
            $a_object = New-HtmlTag @a_element
            #Set objects
            #Add i object to a href
            [void]$a_object.AppendChild($i_object)
            #Add a href to li
            [void]$li_object.AppendChild($a_object)
            #Add li to ul object
            [void]$ul_object.AppendChild($li_object)
        }
        #Create modal
        $p = @{
            Title = "About Author";
            Id = "aboutAuthorModal";
            FooterObject = $ul_object;
            FooterClass = "justify-content-center";
            BodyObject = $modal_body;
            IconHeaderClass = "bi bi-at fa-lg me-2";
        }
        New-HtmlModal @p
    }
    End{
        #Nothing to do here
    }
}
